package com.framework.component.resolver.reflect;

import com.framework.component.resolver.Resolver;

import java.lang.reflect.AccessibleObject;
import java.lang.reflect.Field;

public final class FieldMember extends AccessibleObject implements FieldWrapper {

    private final Field field;
    private final Resolver annoResolver;

    public FieldMember(Field field, Resolver annoResolver) {
        this.field = field;
        this.annoResolver = annoResolver;
    }

    @Override
    public Resolver annoResolver() {
        return this.annoResolver;
    }

    @Override
    public Object get(Object obj) throws IllegalAccessException {
        return field.get(obj);
    }

    @Override
    public void set(Object obj, Object value) throws IllegalArgumentException, IllegalAccessException {
        field.set(obj, value);
    }

    @Override
    public Class<?> getDeclaringClass() {
        return field.getDeclaringClass();
    }

    @Override
    public String getName() {
        return field.getName();
    }

    @Override
    public int getModifiers() {
        return field.getModifiers();
    }

    @Override
    public boolean isSynthetic() {
        return field.isSynthetic();
    }

    @Override
    public void setAccessible(boolean flag) throws SecurityException {
        field.setAccessible(flag);
    }

    @Override
    public String toString() {
        return field.toString();
    }
}
